package indv.cfeng.fianceCampus.serviceCore.service.impl;

import com.alibaba.excel.EasyExcel;
import indv.cfeng.fianceCampus.serviceCore.listener.ExcelDictDtoListener;
import indv.cfeng.fianceCampus.serviceCore.pojo.dto.ExcelDictDto;
import indv.cfeng.fianceCampus.serviceCore.pojo.entity.Dict;
import indv.cfeng.fianceCampus.serviceCore.mapper.DictMapper;
import indv.cfeng.fianceCampus.serviceCore.service.DictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.InputStream;

/**
 * <p>
 * 数据字典 服务实现类
 * </p>
 *
 * @author cfeng
 * @since 2022-10-15
 */
@Service
@Slf4j
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements DictService {
    @Transactional(rollbackFor = {Exception.class})
    @Override
    public void importData(InputStream inputStream) {
        EasyExcel.read(inputStream, ExcelDictDto.class,new ExcelDictDtoListener(baseMapper)).sheet().doRead();
        log.info("importData finish");
    }
}
